#include <bits/stdc++.h>

#define eb emplace_back
#define in read<int>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e5 + 10;
const int V = 1e5;

int n, rt[N], a[N], b[N];
ll f[N];
vec G[N];

namespace seg {
	const int N = 1e7;
	struct line {
		ll k, b;
		ll operator [] (ll x) { return k * x + b; }
	} val[N];
	vector < int > vpot;
	int ndn, ch[N][2];
	int nd() {
		int x = vpot.size() ? vpot.back() : ++ndn; if(vpot.size()) vpot.pop_back();
		val[x].k = 1e9; val[x].b = 1e18; ch[x][0] = ch[x][1] = 0; return x;
	}
	void ins(int &x, line v, int l = -V, int r = V) {
		if(!x) x = nd(); int mid = l + r >> 1;
		if(val[x][mid] > v[mid]) swap(val[x], v);
		if(val[x][l] > v[l]) ins(ch[x][0], v, l, mid); if(val[x][r] > v[r]) ins(ch[x][1], v, mid + 1, r);
	}
	int merge(int x, int y, int l = -V, int r = V) {
		if(!x || !y) return x | y; int mid = l + r >> 1;
		ch[x][0] = merge(ch[x][0], ch[y][0], l, mid); ch[x][1] = merge(ch[x][1], ch[y][1], mid + 1, r);
		ins(x, val[y], l, r); vpot.eb(y); return x;
	}
	ll query(int x, int pos, int l = -V, int r = V) {
		if(!x) return 1e18; if(l == r) return val[x][pos]; int mid = l + r >> 1;
		ll ans = val[x][pos];
		if(pos <= mid) chkmin(ans, query(ch[x][0], pos, l, mid));
		else chkmin(ans, query(ch[x][1], pos, mid + 1, r));
		return ans;
	}
}

void dfs(int x, int p) {
	for(auto y : G[x]) if(y ^ p) dfs(y, x), rt[x] = seg :: merge(rt[x], rt[y]);
	if(G[x].size() == 1 && x != 1) f[x] = 0;
	else f[x] = seg :: query(rt[x], a[x]);
	seg :: ins(rt[x], (seg :: line) { b[x], f[x] });
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin); freopen("CF932F.out", "w", stdout);
#endif
	n = in; rep(i, 1, n) a[i] = in; rep(i, 1, n) b[i] = in;
	rep(i, 2, n) { int u = in, v = in; G[u].eb(v); G[v].eb(u); }
	dfs(1, 0); rep(i, 1, n) printf("%lld ", f[i]); puts("");
	return 0;
}
